home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
g_mouse.zip
/
USER.TXT
< prev
Wrap
Text File
|
1992-09-25
|
10KB
|
246 lines
*****************************************************************************
* *
* Graphics Unit For The Mouse *
* by *
* Jean-Laurent PRADEL *
* *
* Version 1.0 *
* *
*****************************************************************************
Introduction
____________
When I test the TP6 for the first time, my biggest disappointment was
that it was always impossible to program the mouse in graphic mode! After few
weeks, I found a small book about this under TP5. Just the time for my blood
to make a turn in my body and I make my first try...
Here you will find the result of my thinking and some system handing up!
If you don't want to read immediatly all those details, you can try my
demo program which could be programmed in a better way, but it is just here
to show you what I did...
───────────────o───────────────
Types and Constants
In first, there is a type which is used to create the mouse pattern:
Type MousePattern = Record
InsertX : word;
InsertY : word;
Pattern : Array [0..15] of String [16];
End;
The mouse cursor is a small pattern of 16*16 pixels. The variables
InsertX and InsertY define the INSERTION POINT in this pattern; it is the
point in the pattern which define the mouse position.
The array contains the shape of the cursor. For exemple, the arrow is
defined by :
Const Arrow : MousePattern = (InsertX: 2;
InsertY: 1;
Pattern: (' 0 ',
' 020 ',
' 0220 ',
' 02220 ',
' 022220 ',
' 0222220 ',
' 02222220 ',
' 022222220 ',
' 0222222220 ',
' 02222222220 ',
' 0222222000 ',
' 02000220 ',
' 0 0220 ',
' 0220 ',
' 0220 ',
' 00 '));
With my method, there is in the same array the mask and the shape. For
that you need 4 caracters :
- ' ' (Space Caracter) : The background will be displayed.
- '0' : A black point will be displayed.
- '1' : A white point will be displayed.
- '2' : The background will be displayed in the
complementary colour.
I know that it isn't so easy to see the difference between a 1 and a 2
in the middle of others 0, 1 and 2. But it is really easy to type on the
keyboard and easier to read than a set of hexadecimal codes!...
─────o─────
After that, I have defined 7 constants for the codes of the buttons and
4 others for predefined cursors:
Left, Middle, Right, LeftMiddle, MiddleRight, LeftRight, LeftMiddleRight
Arrow, Target, Bomb and QuestionMark.
KingOfMouse is a variable which is initialized by the function TestMouse.
───────────────o───────────────
Procedures
Procedure MouseState(Var dx,dy,button:word);
This procedure brings you back the position of the mouse and the state
of the button (see constants). dx and dy are the real coordinates between 0
and 639. In CGA mode, the dx coordinate is gave in the range 0..639 (like in
EGA or VGA mode).
─────o─────
Procedure ChangeMouse(Drawing:MousePattern);
This procedure changes the mouse cursor with the variable Drawing. The
type MousePattern was explained just before.
─────o─────
Procedure Show_Mouse;
This procedure shows the mouse!!! You must be care, the same procedure
exists in the Drivers unit of TurboVision, but it is called "ShowMouse" and
not "Show_Mouse"!!!
─────o─────
Procedure Hide_Mouse;
This procedure hides the mouse (yeah, really!)!!! And...? You must be
care because blablabla... blabla... blablabla... "HideMouse" blablabla...
"Hide_Mouse"!!!
Nevertheless, it is important to hide the mouse before drawing anything
in the background, if you don't want to see some strange things on the screen.
─────o─────
Procedure WaitBox(x1,y1,x2,y2,button:word);
This procedure waits (!) that the user click in the area (x1,y1),(x2,y2)
with the button "button" (see constants).
─────o─────
Procedure PutMouse(x,y:word);
This procedure moves the mouse to the point (x,y). You don't need to use
Hide_Mouse before this procedure (and of course to use Show_Mouse after).
─────o─────
Procedure WaitButton (Var a,b,button:word);
This procedure waits (!) the user clicks a button and gives you back
the coordinates of the mouse at this moment and which button was used.
─────o─────
Procedure MouseLimits (x1,y1,x2,y2:word);
This procedure defines a box (x1,y1),(x2,y2) out of which the mouse
can't go.
─────o─────
Procedure UnLimitMouse;
This procedure deletes the limits made by the procedure MouseLimits.
─────o─────
Procedure PositionPress (Var x,y,button:word);
This procedure gives you back the position of the mouse when the button
"button" has been pressed at the last time. But, in this case, "button" does
not go with the constants for buttons! If "button" is even then the left-button
is tested, and if "button" is odd then the right-button is tested. I don't
know how to do better (for the moment).
─────o─────
Procedure PositionRelease (Var x,y,button:word);
This procedure gives you back the position of the mouse when the button
"button" has been released at the last time. The variable "button" works like
in PositionPress.
─────o─────
Procedure Box (x,y,l,h,ctour,cint,ctext:word;text:String);
This procedure has nothing to do with the mouse, but I think that it is
really usefull. It draws a box, centred on (x,y), with a length of l and a
height of h. The color of the border is ctour, that of the inside is cint. You
can put a text in with the colour ctext.
───────────────o───────────────
Functions
Function TestMouse:Boolean;
This function is the first thing that you MUST do in your initialization
procedure. This function tests the driver of the mouse.
If there is no driver, the result is False.
If there is a driver active, the result is True.
More, this function initializes the variable KindOfMouse which gives you
the number of buttons on the mouse.
─────o─────
Function TestButton(x1,y1,x2,y2,button:word):boolean;
This function becames True if the mouse is in the box (x1,y1),(x2,y2)
and the button "button" is pressed. In any other case, the function is False.
───────────────o───────────────
That 's all !!!
That 's all, but not at all!!! This unit is the first thing which lives
Bob (Bob is my computer) and my house (euh... my appartment). And of course,
it is possible to do better (with my program and with my english!).
So, I will be very happy if you send me some echos of what happens with
my unit.
I already know a problem... : When you run Windows, this program
changes something in your driver. After that, your driver only recognizes 2
buttons (even if you have a lovely mouse with 3 buttons), and my unit only
sees a mouse with 2 buttons!!!.
For example, I have never try my unit under Hercule Mode (and I'll be
surprised if it works... There is always some problem with Hercule Mode!).
Of course, if you think to send me a letter, it would be very fine to
encourage me with some money (in DM or Francs), I am a poor french chemistry
studiant exile in Germany...
Until June 93: After June 93:
Jean-Laurent PRADEL Jean-Laurent PRADEL
Im Sohlgraben 1A Ch. Piegros Sud
D-3550 MARBURG/CAPPEL Villa Le Sapin Bleu
Germany 83170 BRIGNOLES
France
E-Mail : pidou@astro.chemie.uni-marburg.de
Thank you and a lot of fun....................Danke und viele Spaß